#ifndef PLAYER_H
#define PLAYER_H

#include <QStringList>
#include <string>
#include "Card.h"
#include "Hand.h"
#include"Server.h"
class game;

//Class created by CP botha
using namespace std;

struct Bid
    {
        QString action;
        int num;
        QString suit;//S,H,C,D,NT and pass
    };
/*!
 * \brief The Player class class representing a player with all player information
 */
class Player
{
public :
        int id;//N =1, E=2, S=3, W=4

   Player(Hand, int,game*,Server*);//send hand and id
   //Player(GUI *,Server*,Hand, int);
   //Player(GUI *,Client*,Hand, int);
   /*!
    * \brief getMove ask a player to return a card to play
    * \return card that needs to be played is returned
    */
   virtual Hand getValidMoves();
   virtual Card getMove(bool);  //get move from player
   /*!
    * \brief getBid ask player to return a bid
    * \return QStringList containing bidAction at index 0,trickCount at index 1 and suit at index 2
    */
   virtual QStringList getBid();//get bid from player
   /*!
    * \brief getUsername returns player username/screen name
    * \return return string containing username/screen name
    */
   string getUsername();    //set player username
   /*!
    * \brief setUsername change player username
    * \param string containing username
    * \return true if changed successful and false if failed
    */
   bool setUsername(string);//set player username
   /*!
    * \brief getPartner returns a pointer to player partner
    * \return pointer to player partner
    */
   Player* getPartner();
   /*!
    * \brief setLocalHand set the players localHand
    * \return true if changed successful and false if failed
    */
   virtual bool setLocalHand(Hand);
   int contract;     //to store players contract
   /*!
    * \brief declarer flag set if player is declarer
    */
   bool declarer;
   /*!
    * \brief dealer flag set if player is dealer
    */
   bool dealer;

   /*!
    * \brief getId returns player id
    * \return int containing player id
    */
   int getId();             //returns player id
   /*!
    * \brief sendBid send a bid made by a player
    * \param QString containing bid information
    * \param int id of player who made the bid
    */
   virtual void sendBid(QStringList,int);//send player the last bid
   /*!
    * \brief sendMove send player the last move made
    * \param Card the card that was player
    */
   virtual void sendMove(Card,QString);//send player last card played
   void print();//print player
   /*!
    * \brief moveInvalid alert player that move was invalid
    */
   virtual void moveInvalid();
   /*!
    * \brief bidInvalid alert player that bid was invalid
    */
   virtual void bidInvalid();
   /*!
    * \brief startDealing alert player that dealing is started
    */
   virtual void startDealing();
   /*!
    * \brief startRedealing alert player that redealing is started
    */
  virtual  void startRedealing();
   /*!
    * \brief startBidding alert player that bidding is started
    */
   virtual void startBidding();
   /*!
    * \brief startPlay alert player that play is started
    */
  virtual  void startPlay();
   /*!
    * \brief RubberDone
    */
   virtual void RubberDone();
   /*!
    * \brief sendTrickWinner alert player of the trick winner
    */
   virtual void sendTrickWinner(QString team, QString player);
   /*!
    * \brief sendContract send player the winning contract
    */
   virtual void sendContract(QStringList);
   /*!
    * \brief sendDummy tell the player who the dummy is
    */
   virtual void sendDummyId(string);
   /*!
    * \brief sendDummyCards send player the dummy hand
    */
   virtual void sendDummyCards(Hand);
   /*!
    * \brief sendHand alert player that hand is available
    */
   virtual void sendHand();
   /*!
    * \brief sendGameStatus send current game status to player
    * \param QStringList containing game status
    */
   virtual void sendGameStatus(QStringList);
   /*!
    * \brief startDummy start dummy phase
    */
   virtual void startDummy();
   /*!
    * \brief sendRubberWinner send out who won the rubber
    */
   virtual void sendRubberWinner(QString);

   /*!
    * \brief sendScoreUpdate send player score update
    */

   virtual void sendScoreUpdate(string);
   /*!
    * \brief sendGameWinner send player game winger
    * \param string containing game winner
    */
   virtual void sendGameWinner(QString);
   /*!
    * \brief hasCardsInSuit determine if player has cards of a suit
    * \param char containing suit
    * \return bool showing if player has cards in suit
    */
   bool hasCardsInSuit(char);
   /*!
    * \brief specials stores special bids, D,RD(double redouble)
    */
   string specials;
   /*!
    * \brief dummyFlag flag set true if player is dummy
    */
   bool dummyFlag;
   /*!
    * \brief localHand hand containing player cards
    */
   Hand localHand;
   /*!
    * \brief partner pointer to player partner
    */
   Player* partner;
   /*!
    * \brief updateScore send out score update with the network
    */
   virtual void updateScore(QString, QString, QString, QString);
   /*!
    * \brief highestBid QStringList containig the information of the current highest bid by player
    */
   QStringList highestBid;

   void updateTrump(QChar );
   /*!
    * \brief vulnerable bool flag that is set when the player is vulnerable
    */
   bool vulnerable;
   /*!
    * \brief honourAward calculate honour reward for player
    * \param h hand to calculate honour reward for
    * \return int
    */
   //int honourAward(Hand h);
   /*!
    * \brief honourPoints int containing honour points for a Player
    */
   int honourPoints;
   /*!
    * \brief winner bool flag to determine if the player is a winner
    */
   bool winner;

protected:
   /*!
     * \brief username player username/screen name
     */
    string username;
    /*!
     * \brief position player position, nort, east, south or west
     */
    string position;
    /*!
     * \brief gui pointer to game gui
     */
    game* gui;
    /*!
     * \brief server pointer to server
     */
    Server * server;
    /*!
     * \brief dummyHand hand containing dummy cards
     */
    Hand dummyHand;
    /*!
     * \brief lastBid bid containing last bid information
     */
    Bid lastBid;
};

#endif // PLAYER_H
